package com.natalia.file.config;

import com.natalia.file.service.FileService;
import com.natalia.file.service.impl.local.LocalServiceImpl;
import com.natalia.file.service.impl.minio.MinioServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;

/**
 * @Author yang
 **/
@Configuration
@EnableConfigurationProperties(FileProperties.class)
public class FileConfig {

    @Bean
    @ConditionalOnProperty(prefix = "file", name = "type", havingValue = "local", matchIfMissing = true)
    public FileService localFileService() {
        return new LocalServiceImpl();
    }

    @Bean
    @ConditionalOnProperty(prefix = "file", name = "type", havingValue = "minio")
    public FileService minioFileService() {
        return new MinioServiceImpl();
    }

}
